<!DOCTYPE html>
<html lang="-CN">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>航空订票系统 | 注册</title>
	<link rel="stylesheet" type="text/css" href="admin/lib/layui-v2.5.5/css/layui.css">
	<link rel="stylesheet" type="text/css" href="admin/css/main.css">
	<!--加载meta IE兼容文件-->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
	<![endif]-->
</head>
<body>
<div class="header">
	<div class="menu-btn">
		<div class="menu"></div>
	</div>
	<h1 class="logo">
		<a href="index.html">
			<span>航空订票系统</span>
			<img src="admin/images/favicon.ico" height="60px">
		</a>
	</h1>
	<div class="nav">
		<a href="index.html" class="active">航班查询</a>
		<a href="about.html">关于</a>
	</div>
	<ul class="layui-nav header-down-nav">
		<li class="layui-nav-item"><a href="index.html" class="active">航班查询</a></li>
		<li class="layui-nav-item"><a href="about.html">关于</a></li>
	</ul>
	<p class="welcome-text">
		<span id="username"><a style="color: #1295D8" href="login.html">登录</a></span>
	</p>
</div>

<div class="banner">
	<div class="cont w1000" style="padding-top: 30px;">
		<form class="layui-form layui-form-pane" onsubmit="return false">
			<div class="layui-card" style="max-width: 672px;margin: 0 auto;">
				<div class="layui-card-header">注册 - 请填写以下用户信息</div>
				<div class="layui-card-body">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">身份证号码</label>
							<div class="layui-input-inline">
								<input lay-verify="identity" name="id" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">姓名</label>
							<div class="layui-input-inline">
								<input lay-verify="required" name="name" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">手机号码</label>
							<div class="layui-input-inline">
								<input lay-verify="phone" name="phone" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">邮箱</label>
							<div class="layui-input-inline">
								<input lay-verify="email" name="email" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">出生日期</label>
							<div class="layui-input-inline">
								<input lay-verify="required" name="birth_date" id="birth_date" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">密码</label>
							<div class="layui-input-inline">
								<input lay-verify="required" type="password" name="password" id="password" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">确认密码</label>
							<div class="layui-input-inline">
								<input lay-verify="required" type="password" name="again_password" id="again_password" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div style="margin: 0 auto;width: 30px;">
							<button class="layui-btn admin-button" lay-submit="" lay-filter="register"> 注 册 </button>
						</div>
					</div>
				</div>
			</div>

		</form>
	</div>
</div>


<div class="footer-wrap" style="  text-align: center;padding: 20px;color: #858796;font-size: 18px;">
	<span style="">Copyright ©  2021</span>
</div>
<script type="text/javascript" src="admin/lib/layui-v2.5.5/layui.js"></script>
<script type="text/javascript">
	layui.config({
		base: 'admin/js/util/'
	}).use(['element', 'laydate', 'jquery', 'menu', 'form'], function () {
		var element = layui.element,
			laydate = layui.laydate,
			form = layui.form,
			$ = layui.$,
			menu = layui.menu;

		menu.init();

		laydate.render({elem: '#birth_date'});

		form.on('submit(register)', function (data) {
			var field = data.field;
			if(field.password === field.again_password){
				$.ajax({
					url: "/api/register",
					data: data.field,
					type: "POST",
					dataType: "json",
					success: function (res) {
						if (res.code == 0) {
							layer.msg('注册成功');
							window.location = 'login.html';
						} else {
							layer.msg(res.msg, {icon: 2, time: 2000});
						}
					},
				});
			}else {
				layer.msg('两次密码不一致', {icon: 2, time: 1500});
			}
		});
	})
</script>
</body>
</html>
